// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) definits fieldsfirst ansi space safe 
// Source File Name:   PropertySheet.java

package jones.gui;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.beans.*;
import java.io.PrintStream;
import javax.swing.*;

// Referenced classes of package jones.gui:
//            PropertyEditorPanel, CannotEditPropertyException

public class PropertySheet extends JPanel
{

    private Class beanClass = null;
    private Object beanObject = null;
    private BeanInfo beanInfo = null;
    private JSplitPane jSplitPane1 = null;
    private JPanel jPanel1 = null;
    private JPanel jPanel2 = null;

    public PropertySheet()
    {
        initComponents();
    }

    public PropertySheet(Class beanClass)
    {
        initComponents();
        this.beanClass = beanClass;
        try
        {
            beanInfo = Introspector.getBeanInfo(beanClass);
            beanObject = beanClass.newInstance();
            addPropertyEditorGUIs();
        }
        catch (IntrospectionException ex)
        {
            JOptionPane.showMessageDialog(((java.awt.Component) (this)), ((Object) (ex)), "Class Introspection Error", 0);
        }
        catch (InstantiationException ex)
        {
            JOptionPane.showMessageDialog(((java.awt.Component) (this)), ((Object) (ex)), "Instantiation Exception", 0);
        }
        catch (IllegalAccessException ex)
        {
            JOptionPane.showMessageDialog(((java.awt.Component) (this)), ((Object) (ex)), "Illegal Access Exception", 0);
        }
    }

    public PropertySheet(Object beanObject)
    {
        initComponents();
        this.beanObject = beanObject;
        beanClass = beanObject.getClass();
        try
        {
            beanInfo = Introspector.getBeanInfo(beanClass);
            addPropertyEditorGUIs();
        }
        catch (IntrospectionException ex)
        {
            JOptionPane.showMessageDialog(((java.awt.Component) (this)), ((Object) (ex)), "Class Introspection Error", 0);
        }
    }

    private void initComponents()
    {
        jSplitPane1 = new JSplitPane();
        jPanel1 = new JPanel();
        jPanel2 = new JPanel();
        setLayout(((java.awt.LayoutManager) (new BorderLayout())));
        jSplitPane1.setDividerSize(4);
        jPanel1.setLayout(((java.awt.LayoutManager) (new GridLayout(0, 1))));
        jSplitPane1.setLeftComponent(((java.awt.Component) (jPanel1)));
        jPanel2.setLayout(((java.awt.LayoutManager) (new GridLayout(0, 1))));
        jSplitPane1.setRightComponent(((java.awt.Component) (jPanel2)));
        add(((java.awt.Component) (jSplitPane1)), "North");
        JButton propertyLabel = new JButton("Property:");
        propertyLabel.setHorizontalAlignment(2);
        JButton valueLabel = new JButton("Value:");
        valueLabel.setHorizontalAlignment(2);
        jPanel1.add(((java.awt.Component) (propertyLabel)));
        jPanel2.add(((java.awt.Component) (valueLabel)));
    }

    private void addPropertyEditorGUIs()
    {
        PropertyDescriptor propertyDescriptors[] = beanInfo.getPropertyDescriptors();
        for (int i = 0; i < propertyDescriptors.length; i++)
        {
            PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
            try
            {
                jPanel2.add(((java.awt.Component) (new PropertyEditorPanel(propertyDescriptor, beanObject))));
                JButton propertyLabel = new JButton(propertyDescriptor.getName());
                propertyLabel.setHorizontalAlignment(2);
                jPanel1.add(((java.awt.Component) (propertyLabel)));
            }
            catch (CannotEditPropertyException ex)
            {
                System.out.println("Cannot edit property " + propertyDescriptor.getName());
            }
        }

    }

    public Object getObject()
    {
        return beanObject;
    }

    public static void main(String args[])
    {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(3);
        frame.setContentPane(((java.awt.Container) (new PropertySheet(javax.swing.JPanel.class))));
        frame.pack();
        frame.show();
    }
}
